package org.example.petsystem.service.impl;

import org.example.petsystem.mapper.RegisterMapper;
import org.example.petsystem.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RegisterServiceimpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;
    @Override
    public int checkUserName(String username)
    {//判断用户名是否重复
        Integer user=registerMapper.checkUserName(username);
        if(user==null)
        {
            return 0;
        }
        else
            return 1;

    }
    @Override
    public int checkEmail(String email)
    {//判断邮箱是否重复
        Integer user=registerMapper.checkEmail(email);
        if(user==null)
        {
            return 0;
        }
        else
            return 1;
    }
    @Override
    public int checkPhoneNumber(String phonenumber)
    {//判断手机号是否重复
        Integer user=registerMapper.checkPhoneNumber(phonenumber);
        if(user==null)
        {
            return 0;
        }
        else
            return 1;
    }
    @Override
    public int register(String username, String  name,String  password,  int age,int resource, int state, String phonenumber, String email, String address)
    {
        if(registerMapper.register(username, name, password, age, resource, state, phonenumber, email, address)>0)
            return 1;
        else
            return 0;
        }


}
